package org.javaboy.vhr.controller.borrow;
/**
 * ClassName: BorrowCarController <br/>
 * Description: <br/>
 * date: 2020/3/21 18:41<br/>
 *
 * @author Hesion<br />
 * @version
 * @since JDK 1.8
 */

import org.javaboy.vhr.model.*;
import org.javaboy.vhr.service.BorrowCarService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;

/**
 * @program: vhr
 * @description:
 * @author: hesion
 * @create: 2020-03-21 18:41
 **/
@RestController
@RequestMapping("/borrowInfo/basic/")
public class BorrowCarController {

    @Autowired
    BorrowCarService borrowCarService;

    @GetMapping("/")
    public RespPageBean getBorrowByPage(@RequestParam(defaultValue = "1") Integer page, @RequestParam(defaultValue = "10") Integer size, BorrowBean borrowBean, Date[] beginDateScope) {
        return borrowCarService.getBorrowByPage(page, size, borrowBean, beginDateScope);
    }
@PutMapping("/")
public RespBean changeMileAndSpend(@RequestBody BorrowCar borrowCar){
    if (borrowCarService.changeMileAndSpend(borrowCar) == 1) {

        return RespBean.ok("修改成功!");
    }
    return RespBean.error("修改失败!");
}
    @DeleteMapping("")
    public RespBean deleteCarById(@RequestBody BorrowBean borrowBean) {
        if (borrowCarService.backCar(borrowBean) == 1) {
            return RespBean.ok("还车成功!");
        }
        return RespBean.error("还车失败!");
    }
}
